import java.util.Date;
import java.util.Locale;

import controllers.Helper;

import play.data.format.Formatters.SimpleFormatter;


public class DateFormatter extends SimpleFormatter<Date> {

    @Override
    public Date parse(String text, Locale locale) {
        if (text == null || text.trim().length() == 0)
            return null;
        return Helper.stringToDatetime(text);
    }

    @Override
    public String print(Date value, Locale locale) {
        return value == null  ? "" : Helper.dateToString(value);
    }
}